package cn.lingyangwl.agile.misc.short_link.controller;

import cn.lingyangwl.agile.misc.short_link.model.rqrs.*;
import cn.lingyangwl.agile.misc.short_link.service.*;
import cn.lingyangwl.agile.ram.*;
import cn.lingyangwl.framework.core.response.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 短链访问日志
 * 
 * @author shenguangyang
 */
@Api(tags = "短链访问日志")
@RestController("shortLinkAccessLogController")
@RequestMapping("/linkAccessLog")
public class AccessLogController {
    @Resource
    private AccessLogService accessLogService;

    @ApiOperation(value = "分页-短链访问日志")
    @RamResource(action = "sl:accessLog:query", name = "查询短链访问日志", type = ActionType.READ)
    @GetMapping("/pageAccessLog")
    public Resp<IPage<AccessLogResp>> pageLinkAccessLog(@Validated AccessLogPageReq query) {
        return Resp.ok(accessLogService.pageAccessLog(query));
    }

    @ApiOperation(value = "批量删除-短链访问日志")
    @RamResource(action = "sl:accessLog:delete", name = "删除短链访问日志", type = ActionType.WRITE)
    @DeleteMapping("/batchDeleteAccessLog")
    public Resp<?> deleteBatch(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(accessLogService.deleteAccessLogByIds(ids));
    }
}
